package com.jtzc.aikf.controller;

import com.jtzc.aikf.assistant.XiaoJuAgent;
import com.jtzc.aikf.bean.ChatForm;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@Tag(name = "小矩")
@RestController
@RequestMapping
public class XiaoJuController {
    @Autowired
    private XiaoJuAgent xiaoJuAgent;

    /**
     * 小矩聊天窗口
     */
    @Operation(summary = "对话")
    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String> chat(@RequestBody ChatForm chatForm)  {
        return xiaoJuAgent.chat(chatForm.getMemoryId(), chatForm.getMessage());
    }

}
